Problem = function() {
  this.test = 3;
  //this.initialState = new Array (8,2,4,3,1,5,6,7,null);
  this.initialState = new Array (0,1,2,3,4,5,6,7,8);
  this.goalState = new Array (0,1,2,3,4,5,6,7,8);
};

Array.prototype.find = function(searchStr) {
  var returnArray = false;
  for (i=0; i<this.length; i++) {
    if (typeof(searchStr) == 'function') {
      if (searchStr.test(this[i])) {
        if (!returnArray) { returnArray = [] }
        returnArray.push(i);
      }
    } else {
      if (this[i]===searchStr) {
        if (!returnArray) { returnArray = [] }
        returnArray.push(i);
      }
    }
  }
  return returnArray;
};

Array.prototype.shuffle = function (){ 
        for(var rnd, tmp, i=this.length; i; rnd=parseInt(Math.random()*i), tmp=this[--i], this[i]=this[rnd], this[rnd]=tmp);
};

Problem.prototype.goalTest = function(state) {
//	if (state.compare(this.goalState)) {	return 1;}
    if (state.toString() == this.goalState.toString()) { return 1;}
	else {return 0;}
};

Problem.prototype.Successors = function(state) {
  arraySuccessors = new Array();
  if (EmptyBlockIs()) {
    //var EmptyBlock = new PieceCenter;
  };
  return arraySuccessors;
};

//inherit the Linked list
/*
LinkedList.Circular = function() {};
LinkedList.Circular.prototype = new LinkedList();

LinkedList.Circular.prototype.append = function(node) {
  if (this.first === null) {
    node.prev = node;
    node.next = node;
    this.first = node;
    this.last = node;
  } else {
    node.prev = this.last;
    node.next = this.first;
    this.first.prev = node;
    this.last.next = node;
    this.last = node;
  }
  console.log(node.data);
  this.length++;
};

LinkedList.Circular.prototype.remove = function(node) {
  console.log(node.data);
  if (this.length > 1) {
    node.prev.next = node.next;
    node.next.prev = node.prev;
    if (node == this.first) { this.first = node.next; }
    if (node == this.last) { this.last = node.prev; }
  } else {
    this.first = null;
    this.last = null;
  }
  node.prev = null;
  node.next = null;
  this.length--;
};

LinkedList.Circular.prototype.printAll = function() {
  var current = this.first;
  for (var i=0; this.length > i; i++) {
    console.log(current.data);
	current = current.next;
  };
};

LinkedList.Node = function(data) {
  this.prev = null; this.next = null;
  this.data = data;
};

test1 = new LinkedList.Node("test1");
test2 = new LinkedList.Node("test2");
test3 = new LinkedList.Node("test3");
test4 = new LinkedList.Node("test4");

myList = new LinkedList.Circular();

console.log("Appending a few nodes...");
myList.append(test1);
myList.append(test2);
myList.append(test3);
console.log("PrintAll nodes...");
myList.printAll();
console.log("Removing test1 node");
myList.remove(test1);
console.log("PrintAll nodes...");
myList.printAll();
*/

myProblem = new Problem();
console.log(myProblem.goalTest(myProblem.initialState));
/*console.log("Hello");
console.log(myProblem.test);
console.log(myProblem.goalState.length);

while(myProblem.goalState.length > 0) {
  console.log(myProblem.goalState.shift());
};     
*/          